// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database() // 初始化数据库
// 云函数入口函数
exports.main = async (event, context) => {
  let count =await getCount();
  count = count.total;
  let list = []
  for (let i = 0; i < count; i += 100) {//自己设置每次获取数据的量
    list = list.concat(await getList(i));
  }
  return list;
}
async function getCount() {//获取数据的总数，这里记得设置集合的权限
  let count = await db.collection('th_cards').where({
  }).count();
  return count;
}
async function getList(skip) {//分段获取数据
  let list = await db.collection('th_cards')
  .orderBy('addtime','desc').skip(skip).get();
  return list.data;
}